package com.yykt.weshare.interceptor;

import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Slf4j
@Configuration
public class AppInterceptorConfig implements WebMvcConfigurer {

    @Autowired
    AppInterceptor appInterceptor;

    @Autowired
    AdminInterceptor adminInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.info("AppInterceptor registry begin");
        registry.addInterceptor(appInterceptor)
                .addPathPatterns("/app/**");

        // TODO: 添加更多的 interceptor，注意，interceptor 不能包含 context-path
        registry.addInterceptor(adminInterceptor)
                .addPathPatterns("/admin/**")
                .excludePathPatterns("/admin/login");

    }
}
